package com.company.gas.service.impl;

import com.company.gas.mapper.CustomerMapper;
import com.company.gas.pojo.Customer;
import com.company.gas.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CustomerServiceImpl implements ICustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public List<Customer> queryCustomerList() {
        List<Customer> customerList = customerMapper.selectAll();
        for(Customer customer : customerList){
            System.out.println(customer);
        }
        return customerList;
    }

    @Override
    public Customer queryCustomerById(String cusId) {
        Customer customer = customerMapper.queryCustomerById(cusId);
        System.out.println(customer);
        return customer;
    }

    @Override
    public int addCustomer(String cusId, String cusName, String cusPhnum, String cusAdr, Integer flag, Date createTime, String createBy, Date modifyTime, String modifyBy) {
        customerMapper.addCustomer(cusId,cusName,cusPhnum,cusAdr,flag,createTime,createBy,modifyTime,modifyBy);
        return 1;
    }

    @Override
    public int updateCustomer(String cusId,String cusName, String cusPhnum,String cusAdr,Integer flag, Date modifyTime, String modifyBy) {
        customerMapper.updateCustomer(cusId,cusName,cusPhnum,cusAdr,flag,modifyTime,modifyBy);
        return 1;
    }

    @Override
    public int deleteCustomer(String cusId) {
        customerMapper.deleteCustomer(cusId);
        return 1;
    }
}